unit cubez;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ImgList, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Shape1: TShape;
    Shape3: TShape;
    Shape4: TShape;
    Shape5: TShape;
    Shape6: TShape;
    Shape7: TShape;
    Shape8: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  old1,old2,new1,new2:integer;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin

      Shape13.Visible:=False;
      Shape8.Visible:=False;
      Shape5.Visible:=False;
      Shape7.Visible:=False;
      Shape3.Visible:=False;
      Shape9.Visible:=False;
      Shape15.Visible:=False;
      Shape4.Visible:=False;
      Shape12.Visible:=False;
      Shape6.Visible:=False;
      Shape16.Visible:=False;
      Shape11.Visible:=False;
      Shape10.Visible:=False;
      Shape14.Visible:=False;
Form1.Refresh;

repeat
  For i:=1 to 30 do
  begin
    new1:=Random(6);
    Sleep(6);
  end;
until new1<>old1;

repeat
  For i:=1 to 30 do
  begin
    new2:=Random(6);
    Sleep(6);
  end;
until new2<>old2;


Case new1  of
  1:  Shape13.Visible:=True;
  2:
    begin
      Shape8.Visible:=True;
      Shape15.Visible:=True;
    end;
  3:
    begin
      Shape13.Visible:=True;
      Shape8.Visible:=True;
      Shape15.Visible:=True;
    end;
  4:
    begin
      Shape15.Visible:=True;
      Shape8.Visible:=True;
      Shape5.Visible:=True;
      Shape7.Visible:=True;
    end;
  5:
    begin
      Shape13.Visible:=True;
      Shape8.Visible:=True;
      Shape5.Visible:=True;
      Shape7.Visible:=True;
      Shape15.Visible:=True;
    end;
  6:
    begin
      Shape15.Visible:=True;
      Shape8.Visible:=True;
      Shape5.Visible:=True;
      Shape7.Visible:=True;
      Shape3.Visible:=True;
      Shape9.Visible:=True;
    end;
  else Button1Click(Form1);
  end;

Case new2 of
  1:  Shape4.Visible:=True;
  2:
    begin
      Shape12.Visible:=True;
      Shape14.Visible:=True;
    end;
  3:
    begin
      Shape4.Visible:=True;
      Shape12.Visible:=True;
      Shape14.Visible:=True;
    end;
  4:
    begin
      Shape14.Visible:=True;
      Shape12.Visible:=True;
      Shape6.Visible:=True;
      Shape16.Visible:=True;
    end;
  5:
    begin
      Shape4.Visible:=True;
      Shape12.Visible:=True;
      Shape6.Visible:=True;
      Shape16.Visible:=True;
      Shape14.Visible:=True;
    end;
  6:
    begin
      Shape14.Visible:=True;
      Shape12.Visible:=True;
      Shape6.Visible:=True;
      Shape16.Visible:=True;
      Shape11.Visible:=True;
      Shape10.Visible:=True;
    end;
  else Button1Click(Form1);
  end;

old1:=new1;
old2:=new2;


end;

procedure TForm1.FormShow(Sender: TObject);
begin
old1:=0;
old2:=0;
Button1Click(Form1);
end;

end.
